<template>
	<view class="inviteBox">
		<div style="height: 50rpx;"></div>
		<Title :title="title" />
		<view class="boxSty">
			<view class="between ml-16 pt-31 mr-24">
				 <view class="flex-start">
					<image src="../../../../static/images/user/newUI/profilePicture.png" mode="" class="w-110 h-110"></image>
					<view class=" ml-20 mt-10">
						<h3 class="fz24 text-white">我的邀请码</h3>
						<p class="fz46 font-bold text-white">{{scoreInfo.agent_code}}</p>
					</view>
				 </view>
				<view class="copySty" @click="copyToClipboard(scoreInfo.agent_code)">
					<image src="../../../../static/images/user/newUI/copyIcon.png" mode="" class="w-22 h-22 ml-15 mt-8"></image>
					<p class="">复制邀请码</p>
				</view>
			</view>
				<view class="rounded-20 evenly mt-35">
					<view class="flex-start flex inviteGetSty">
						<image src="../../../../static/images/user/newUI/getNum.png" mode="" class="w-85 h-85 ml-21"></image>
						<view class="ml-5">
							<h3 class="fz20 font-bold  mt-30" style="color:#46637C;">邀请获得积分</h3>
							<p style="font-size: 30rpx; color: #333; margin-top:12rpx;margin-bottom: 30rpx;font-weight: 600;">{{total}}积分</p>
						</view>
					</view>
					<view class="flex-start flex inviteGetSty">
						<image src="../../../../static/images/user/newUI/inviteUser.png" mode="" class="w-85 h-85 ml-21"></image>
						<view class="ml-5">
							<h3 class="fz20 font-bold mt-30" style="color:#46637C;">邀请用户</h3>
							<p style="font-size: 30rpx; color: #333;margin-top:12rpx;margin-bottom: 30rpx;font-weight: 600;">{{scoreInfo.count}}人</p>
						</view>
					</view>
				</view>
		</view>
		<view class="GeneratePoster">
			<p @click="generatePoster">生成海报链接</p>
		</view>
		<p class="text-111 fz30 ml-40 font-bold mt-20">成功邀请</p>
		<view class="ml-24 mr-24 bg-white rounded-26 mt-32">
			<view class="infoSty" v-for="item in successList">
				<p class="text-333 fz26 ml-24 font-bold w-245 mt-34 mb-34">{{item.username}}</p>
				<p class="text-888 fz24">{{item.invite_time}}</p>
				<p class="text-red fz24 mr-24"> +{{item.invite_score}}积分</p>
			</view>
		</view>
		<!-- <view class="h-30"></view> -->
		<div v-if="nomore" class="center text-gray-500 fz24 pt-20 pb-20">没有更多了</div>
	</view>
</template>

<script>
	import Title from './../components/title.vue'
	import { getInvitationScoreList, getInvitationScoreTotal, getInvitationInfo } from '@/api/user'
	
	export default {
		components: {
			Title
		},
		data() {
			return {
				title: '我的邀请',
				scoreInfo: {},
				total: 0,
				nomore: false,
				successList: []
			}
		},
		async mounted() {
			// this.getInvitationInfo(),
			// this.geScoreTotal(),
			// this.getList()
			await Promise.all([
				this.getList(),
				this.geScoreTotal(),
				this.getInvitationInfo()
			])
		},
		methods: {
			back() {
				uni.navigateBack()
				// this.cback()
			},
			// 获取我的邀请列表
			getList() {
				const that = this;
				that.$u.api.user.getInvitationScoreList({
					page: 1
				}).then(res => {
					console.log('1222', res)
					if (res.length == 0) {
						this.nomore = true
					} else {
						this.successList = res
					}
				})
			},
			geScoreTotal() {
				const that = this;
				that.$u.api.user.getInvitationScoreTotal().then(res => {
					console.log('0000000', res)
					this.total = res.total
				})
			},
			getInvitationInfo() {
				const that = this;
				that.$u.api.user.getInvitationInfo().then(res => {
					console.log('111', res)
					this.scoreInfo = res
				})
			},
			generatePoster() {
				uni.navigateTo({
					url: '/pages/tabbar/newUser/Invite/invitePoster'
				})
			},
			// 复制文本到剪切板
			copyToClipboard(text) {
			    uni.setClipboardData({
			        data: text,
			        success: function () {
			            uni.showToast({
			                title: '复制成功',
			                icon: 'success',
			                duration: 2000
			            });
			        },
			        fail: function () {
			            uni.showToast({
			                title: '复制失败',
			                icon: 'none',
			                duration: 2000
			            });
			        }
			    });
			}
		}
	}
</script>

<style lang="less">
	page {
		background: #F6F7FB;
	}
	.inviteBox {
		background-image: url('/static/images/user/newUI/inviteBg.png');
		background-size: 100% 100%;
		.boxSty {
			background: linear-gradient(104.43deg, #278AFF 47.02%, #71F1FF 89.77%);
			// background-image: url('../../../static/images/user/newUI/copyBoxBg.png');
			// background-size: 100% 100%;
			// width: 100%;
			height: 350rpx;
			border-radius: 20rpx;
			margin-top: 40rpx;
			margin-left: 21rpx;
			margin-right: 21rpx;
		}
	}
	.copySty {
		width: 182rpx;
		height: 53rpx;
		background-image: url('../../../../static/images/user/newUI/copyBg.png');
		display: flex;
		justify-content: flex-start;
		align-items: center;
		p {
			color: #0064A2;
			font-size: 24rpx;
			font-weight: 600;
			margin-left: 12rpx;
		}
	}
	.inviteGetSty{
		background: linear-gradient(82.81deg, #F0F7FF 28.89%, rgba(255, 255, 255, 0.25) 98.97%);
		width: 46%;
		border-radius: 20rpx;
	}
	.GeneratePoster {
		background: linear-gradient(90deg, #278AFF 0%, #52EEFF 100%);
		width: 96%;
		height: 94rpx;
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 32rpx;
		line-height: 94rpx;
		text-align: center;
		color: #fff;
		border-radius: 500rpx;
		margin: 26rpx auto;
		box-shadow: 0px 4px 13.8px 0px #DEE1EF;
		
		box-shadow: -2px -6px 9.9px 0px #71D0FF inset;
		
		box-shadow: -4px 5px 6.5px 0px #C8FBFF75 inset;

	}
	.infoSty {
		min-height: 80rpx;
		// width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1rpx solid #E3E3E3;
		margin-left: 24rpx;
		margin-right: 24rpx;
	}
	.infoSty:last-child{
		border-bottom: none;
	}
</style>
